﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 地图生成器，根据坐标系生成唯一的一组随机值,来确定一级星系（银河级）随机数，二级星系（恒星系）的,以及行星分布随机数.
/// </summary>
public class RandomCenter  {

    public static List<float> CreateRandomValues(PositionData data)
    {
        List<float> randoms = new List<float>();

        randoms.Add(GetThreeGalaxy(data));
        //randoms.Add(GetTwoGalaxy(data));
       // randoms.Add(GetOneGalaxy(data));

        return randoms;
    }

    //获取第一个数据，行星级随机数
    static float GetThreeGalaxy(PositionData data)
    {
        float temp = 0;

        temp = (data.x.LightYearValue / 5 + data.y.LightYearValue / 5 + data.z.LightYearValue / 5) * 10f;

        return temp;
    }

    //获取第二个随机值，恒星级随机值
    static float GetTwoGalaxy(PositionData data)
    {
        float temp = 0;

        temp = (data.x.AuValue / 100 + data.y.AuValue / 100 + data.z.AuValue / 100) * 3f + (data.x.LightYearValue  + data.y.LightYearValue + data.z.LightYearValue) * 5f;

        return temp;
    }

    //获取第三个随机值，银河级随机值
    static float GetOneGalaxy(PositionData data)
    {
        float temp = 0;

        for (int i = 0; i < data.x.Infinite_Distance.Count; i++)
        {
            temp += data.x.Infinite_Distance[i];
            for (int j = 0; j < data.y.Infinite_Distance.Count; j++)
            {
                temp += data.y.Infinite_Distance[j];
                for (int m = 0; m < data.z.Infinite_Distance.Count; m++)
                {
                    temp += data.z.Infinite_Distance[m];
                }
            }
            
        }

        temp += (data.x.YlyValue + data.y.YlyValue + data.z.YlyValue)/100f;
        temp += (data.x.LightYearValue + data.y.LightYearValue + data.z.LightYearValue)/100f;

        return temp;
    }
}
